package com.sibu.yx.promotion.admin.web.support.filter;


import com.doubo.common.util.StringUtil;

import javax.servlet.http.HttpServletRequest;

/**
 * @author     ：yuwenbo
 * @date       ：Created in 2019/4/15 16:39
 * @description：
 */
@Deprecated
public class TokenSubject extends  AbstractSubject {

    private HttpServletRequest request;


    private Long uid;

    private Boolean isAuthenticated=false;



    public TokenSubject(HttpServletRequest request){
        this.request=request;
        this.init();
    }

    private void init(){
        String token=request.getHeader("MALL_TOKEN");
        String uid=request.getHeader("UID");
        if(StringUtil.isNull(token)||StringUtil.isNull(uid)){
           return;
        }
        Long paramId=Long.parseLong(uid);
        //Long redisUid=RedisTemplateUtil.getLong(token);
        Long redisUid=1L;
        if(!StringUtil.isNull(redisUid)&&redisUid.longValue()==paramId.longValue()){
            this.uid=redisUid;
            isAuthenticated=true;
        }
    }

    @Override
    public Object getPrincipal() {
        return uid;
    }

    @Override
    public boolean isAuthenticated() {
        return isAuthenticated;
    }


}
